<template>
  <div>
    <h3>showTime2 全局组件</h3>
    <h2 :style = "{'color':color}">当前时间为:{{ time }}</h2>
  </div>
</template>

<script>
import dayjs from "dayjs";

export default {
  name: "showTime2",
  data() {
    return {
      time: undefined,
      color:undefined,
    }
  },
  created() {
    this.init();
    console.log(this.$showTimeParams)
    this.setColor()
  },
  mounted() {
    setInterval(() => {
      this.init()
    }, 1000)
  },
  methods: {
    init() {
      this.time = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')
    },
    setColor(){
      this.color = this.$showTimeParams.color || 'black'
    }
  }
}
</script>

<style scoped>

</style>
